#!/usr/bin/perl -w
# Tagwire PluginData Cleaner
#
# $Id: tagwire-pdcleaner.cgi 105 2005-07-13 00:35:24Z ogawa $
#
# This software is provided as-is. You may use it for commercial or 
# personal use. If you distribute it, please keep this notice intact.
#
# Copyright (c) 2005 Hirotaka Ogawa

use strict;
local $|=1;

my($MT_DIR);
BEGIN {
    if ($0 =~ m!(.*[/\\])!) {
        $MT_DIR = $1;
    } else {
        $MT_DIR = './';
    }
    unshift @INC, $MT_DIR . 'lib';
    unshift @INC, $MT_DIR . 'extlib';
}

use MT;
use MT::Blog;
use MT::PluginData;

print "Content-Type: text/html\n\n";
print <<HTML;
<html>
<head><title>Tagwire PluginData Cleaner</title></head>
<body>
<h1>Tagwire PluginData Cleaner</h1>
HTML

my $mt = MT->new;
my $iter = MT::Blog->load_iter();
while (my $b = $iter->()) {
    while (my $pd = MT::PluginData->load({ plugin => 'Tagwire Plugin',
					   key => $b->id })) {
	$pd->remove;
	print ".";
    }
}

print <<HTML;
<p><strong>PluginData successfully removed.</strong></p>
</body>
</html>
HTML
